<template>
<div class="carousel">
  <swiper :options="swiperOption" v-if="showCarousel">
    <!-- slides -->
    <swiper-slide v-for="item in list" :key="item.id">
    <img class="carousel-img" :src="item.imgUrl" />
    </swiper-slide>
    <!-- Optional controls -->
    <div class="swiper-pagination"  slot="pagination"></div>
  </swiper>
</div>
</template>
<script>
export default{
  name: 'HomeCarousel',
  props: {
    list: Array
  },
  data () {
    return {
      swiperOption: {
        pagination: '.swiper-pagination',
        loop: true
      }
    }
  },
  computed: {
    showCarousel () {
      return this.list.length
    }
  }
}
</script>
<style lang="stylus" scoped>
.carousel >>> .swiper-pagination-bullet-active
  background: #fff
.carousel
  overflow: hidden
  width: 100%
  height: 0
  padding-bottom: 31.25%
  background: #eee
 .carousel-img
   width: 100%
 .swiper-pagination-bullet-active
   color: #ffffff
</style>
